home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 5
/
Amoszine 5.adf
/
arts
/
int2.asc.cm
/
int2.asc.cm
Wrap
Text File
|
1992-02-26
|
6KB
|
130 lines
@6 Understanding the Interface
@5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Part 2 - BUTTONS
~~~~~~
@4
In the first part, you learned how to open a resource screen and
display the images from it to create a box. We now need to turn
this solitary box into a working requester. For this, you need
to know how to output text to the screen in the interface program
and how to create a button. Firstly we shall write some text
into the box. The interface instruction to do this is called
PRint. Here is an example of its use:
@3
a$=a$+"PRint 10,10,'Click me!!!!',7;"
@4
The first two parameters that PRint needs are the X and Y
coordinates. Next the actual message you wish to display is
enclosed within SINGLE quotes followed by the pen colour which I
decided would be 7 ended with a semicolon. Don't forget the
semicolon! That's there all is to it! Nice and simple, so far.
Insert that line of code into your interface program and try it
out.
Next, we need to set up a clickable area for a button plus we
need to actually draw the button. First you shall see how to
unpack a single image from the resource bank. We are going to
be using image number 13 and 14 which are the images for an
untouched button and a clicked button respectively. The
interface instruction to unpack an image is unsurprisingly UNpack
which takes 3 parameters. Here's how to use it:
@3
a$=a$+"UNpack 100,20,13;"
@4
The parameters are (in order):
1) The X coordinate
2) The Y coordinate
3) The 13th image from the resource bank, which is a button.
It is important to note that when using images from the resource
bank for gadgets, you need to know their exact dimensions. The
button we unpacked earlier is 64 pixels wide and 16 pixels high.
With this information you can set up a zone which fits the image
perfectly.
Now is the time to actually see the resource bank, so load AMOS
Professional if it isn't already and select 'Resource Ed.' from
the 'User' menu. When the resource bank creator has loaded,
click on the 'Load a bank' button. Select the APSystem folder
and double click on the file 'AMOSPro_Default_Resource.Abk'.
When it has loaded you should see a screen full of different
buttons. Click on 'Edit Graphic Elements'. A button on the
screen should now flash and element number 1 should be
highlighted in a selection box on the control panel. Element
number 1 is the image we used to draw the 3d box in part1. If
you click on different elements in the requester, different
buttons will flash. If you drag the slider bar down, the list of
elements will scroll up or down. If you click on element 13 then
the button which you used earlier will flash. Take note of it's
dimensions, 64 * 16. Exactly what we used before. If you click
on element 14, the clicked button is highlighted. If you want to
find the dimensions of a button, you use this requester. Now
click on exit and then on quit.
Load the file 'Interface_Example2.AMOS' into the editor now and
run it. Impressive eh? Now study the source code. You will
notice that there are two new interface commands in that last
listing. Namely BUtton and ButtonQuit (or BQ). The BUtton
command takes the following parameters:
@3
BU Identification number,X,Y,width,height,initial setting,
minimum,maximum;[][]
@4
Most of the parameters are self-explanatory. The Initial setting
is the button before it is clicked. The minimum value is the
very least value the button can take and the maximum value is the
maximum value the button can take. When the value reaches the
maximum value, it is reset to it's minimum value. See the
explanation in the source code. The first set of square brackets
should contain instructions that are to be executed when the
button is first drawn. The second set of square brackets contain
instructions that are executed when the button is clicked. In
the example, the clicked image of a button is unpacked to the
screen. When the button is clicked, the image on the screen is
replaced with the clicked image therefore giving the impression
of depth. The ButtonQuit command forces an exit from the
interface program as soon as the button is clicked.
The interface program is complete, all thats needed now is a loop
which waits for a button click. A function called Dialog is used
to read the interface channel. It is used like this:
@3
BUTTON=Dialog(1)
@4
The identification number of the button clicked is returned to
the BUTTON variable. With this in mind you can branch to some
part of your program depending upon what value is contained
within the variable. The 1 in the brackets is simply the
interface channel. Now we have the command to read the interface
program, you need a loop which will continue looping until some
value is returned into BUTTON. If no button is clicked the value
of zero remains in the variable. Look at the end of the listing
for the loop to achieve this.
This simple routine can be used to display error messages for
example. The only problem is that the dialogue box will destroy
any background graphics beneath it. So two commands are provided
called SIze and SAve. SIze is used after a BAse command and it
expects two parameters. The width and height of the box. This
is needed so that the entire graphic under the box will be saved.
Afterwards, you need to actually save the image data. SAve only
requires one parameter which is an indentification number. Now
load 'Interface_Example3.AMOS' and run it. You will notice that
when the button is clicked this time, the dialogue box is removed
from the screen, just what we want. Decrease the values after
the SIze command. Notice that some of the box is left behind.
The last example is a basis for a very useable message box, all
it needs is to be put in a procedure, then you can use it
anywhere.@4
Load the file 'Interface_Example4.AMOS' and run it. You are
invited to choose the best computer!!! Choose correctly, you may
be electricuted!!!!! The new interface command in this listing
is ButtonReturn (or BR) and it expects 1 parameter. BR will
force the button to a different state as stated by the parameter.
Look at the explanation in the source code for more detail.
Believe it or not, that last example is the basis for a real
requester with several buttons!